
function Set-InsightADFv2 {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)][Parameters]$Parameters
    )

    # Create a new ADFv2.
    Write-Host # Newline.
    Write-Host "Creating a new Azure Data Factory v2. This might take a few minutes..."
    $params = @{
        ResourceGroupName = $Parameters.Azure.ResourceGroup
        ADFv2Name = $Parameters.LSInsight.ADFv2.Name
        AzureLocation = $Parameters.LSInsight.Location
    }
    $Parameters.LSInsight.ADFv2.Name = New-AzureDataFactoryV2 @params

    # Insert values into arm_template_parameters.
    Complete-ArmTemplateParameterFile -Parameters $Parameters

    # Configure the ADFv2.
    $params = @{
        ResourceGroupName = $Parameters.Azure.ResourceGroup
        ADFv2Name = $Parameters.LSInsight.ADFv2.Name
        ProjectTemplateFile = $Parameters.LSInsight.ArmTemplateFile
        ProjectTemplateParameterFile = $Parameters.LSInsight.ArmTemplateParameterFile
        LSCentralPassword = $Parameters.LSCentral.Server.Credential.Password
        LSInsightPassword = $Parameters.LSInsight.Server.Credential.Password
    }
    Set-AzureDataFactoryV2 @params

}
